﻿namespace Yipusoft.Account.BLL
{
    using System;
    using System.Collections.Generic;
    using Yipusoft.Account.DAL;
    using Yipusoft.Account.Model;

    public class User
    {
        public static bool AddRole(string UserID, string RoleID)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.AddRole(UserID, RoleID);
        }

        public static bool Delete(string UserID)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.Delete(UserID);
        }

        public static bool Exsits(string UserID)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.Exsits(UserID);
        }

        public static List<UserInfo> GetList(string StrWhere)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.GetList(StrWhere);
        }

        public static List<MenuInfo> GetMenuList(string UserID)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.GetMenuList(UserID);
        }

        public static UserInfo GetOAUserInfo(string userId, string password)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.GetOAUserInfo(userId, password);
        }

        public static List<PermissionInfo> GetPermissionList(string UserID)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.GetPermissionList(UserID);
        }

        public static List<RoleInfo> GetRoleList(string UserID)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.GetRoleList(UserID);
        }

        public static UserInfo GetUser(string UserID)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.GetUser(UserID);
        }

        public static bool HasPermission(string UserID, string PermissionID)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return GetPermissionList(UserID).Exists(delegate (PermissionInfo p) {
                return p.PermissionID == PermissionID;
            });
        }

        public static bool HasRole(string UserID, string RoleID)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return GetRoleList(UserID).Exists(delegate (RoleInfo r) {
                return r.RoleID == RoleID;
            });
        }

        public static bool Insert(UserInfo User)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.Insert(User);
        }

        public static bool RemoveRole(string UserID, string RoleID)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.RemoveRole(UserID, RoleID);
        }

        public static bool Update(UserInfo User)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.Update(User);
        }

        public static int ValidateLogin(string UserID, string Password)
        {
            Yipusoft.Account.DAL.User user = new Yipusoft.Account.DAL.User();
            return user.ValidateLogin(UserID, Password);
        }
    }
}

